import axios from '@/libs/api.request'
import qs from 'qs'

// 根据字典码获取字典表
export const getSelectOption = (params) => {
  return axios.request({
    url: 'admins/dataDict/getDictByCode?t='+new Date().getTime(),
    method: 'get',
    params
  })
}

// 新增事件记录
export const addEvent = (data) => {
  return axios.request({
    url: 'admins/eventRecord/add',
    method: 'POST',
    data: qs.stringify(data)
  })
}

// 新增缺陷记录
export const addDefect = (data) => {
  return axios.request({
    url: 'admins/defectFollower/addOnce',
    method: 'POST',
    data: qs.stringify(data)
  })
}

// 搜索缺陷记录
export const searchDefect = (params) => {
  return axios.request({
    url: 'admins/defectFollower/page?t='+new Date().getTime(),
    method: 'get',
    params
  })
}

// 删除缺陷记录

export const removeDefect = (data) => {
  return axios.request({
    url: 'admins/defectFollower/delete',
    method: 'POST',
    data: qs.stringify(data)
  })
}

// 搜索事件记录
export const searchEvent = (params) => {
  return axios.request({
    url: 'admins/eventRecord/page?t='+new Date().getTime(),
    method: 'get',
    params
  })
}

// 删除事件记录

export const removeEvent = (data) => {
  return axios.request({
    url: 'admins/eventRecord/delete',
    method: 'POST',
    data: qs.stringify(data)
  })
}

// 修改事件记录
export const updateEvent = (data) => {
  return axios.request({
    url: 'admins/eventRecord/edit',
    method: 'POST',
    data: qs.stringify(data)
  })
}

// 修改缺陷记录
export const updateDefect = (data) => {
  return axios.request({
    url: 'admins/defectFollower/editBatch',
    method: 'POST',
    data: qs.stringify(data)
  })
}

//添加至问题跟踪
export const addIssure = (data) => {
  return axios.request({
    url: 'admins/eventRecord/addIssure',
    method: 'POST',
    data: qs.stringify(data)
  })
}

//添加至问题跟踪
export const addProgress = (data) => {
  return axios.request({
    url: 'admins/defectFollower/addBatch',
    method: 'POST',
    data: qs.stringify(data)
  })
}

//上传文件
export const upfile = (data) => {
  return axios.request({
    url: 'admins/upload/uploadFile',
    method: 'POST',
    data: data
  })
}

//查找问题跟踪
export const seachWenti = (params) => {
  return axios.request({
    url: 'admins/defectFollowerProgress/findByDefectFollowerId?t='+new Date().getTime(),
    method: 'get',
    params
  })
}
//查找问题跟踪
export const seachJiHua = (params) => {
  return axios.request({
    url: 'admins/defectFollowerAttach/findByDefectFollowerId?t='+new Date().getTime(),
    method: 'get',
    params
  })
}

//导出事件记录
export const eventRecordDown = (params) => {
  return axios.request({
    url: 'admins/eventRecord/download?t='+new Date().getTime(),
    method: 'get',
    responseType: 'blob',
    params
  })
}
//导出问题跟踪
export const downExcel = (params) => {
  return axios.request({
    url: 'admins/defectFollower/download?t='+new Date().getTime(),
    method: 'get',
    responseType: 'blob',
    params
  })
}
//发送邮件
export const sendEmail = (params) => {
  return axios.request({
    url: 'admins/defectFollower/sendEmail?t='+new Date().getTime(),
    method: 'get',
    params
  })
}
